
var url = "http://127.0.0.1:6001/"

function getVersion(cb){

	$.post('/version',null,function(data){
	  if(data)
	  {
		cb(data)
	  }
	});
}

function getStock(stockId,cb)
{	
	var stock={
	    code:'000001.SZ',
	    start_date:'20190701',
	    end_date:'20190705',
	}
	stock = JSON.stringify(stock)
	// stock = null
	// console.log(stock)
	$.get('/quant?s='+stock,function(data){
	  if(data)
	  {
		cb(data)
	  }
	});

}

/*
	fastify 不支持 application/x-www-form-urlencoded 类型
*/
function getStock2(stockId,cb)
{	
	var stock={
	    code:'000001.SZ',
	    start_date:'20190601',
	    end_date:'20190705',
	}

	// console.log(typeof(stock))
	// $.post('/quant2',stock,function(data){
	//   if(data)
	//   {
	// 	cb(data)	
	//   }
	// },"application/json");

	stock = JSON.stringify(stock)
    $.ajax({
        type: "POST",
        url: url+"quant2",
        data:stock,
        beforeSend: function(request) {
            request.setRequestHeader("Content-Type", "application/json");
        },
        success: function(result) {
            // result = JSON.parse(result);
            cb(result)
        }
    });
}

function update(){

}


var tv = 60*1000
setInterval(update,tv)